﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;

namespace DetectingKinectSencor
{
    public class Clock : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private string TimeElapsed;
        private DispatcherTimer timer;
        private Stopwatch stopWatch;

        public static String dateTimeFormatWithPoints = "dd.MM.yyyy HH:mm:ss";
        public static String dateTimeFormatWidthHyphen = "dd-MM-yyyy HH:mm:ss";
        public static String datetimeFormatForFilePath = "d_M_yyyy_H_m_s";
        public static String dateTimeForamtWithMilliseconds = "HH:mm:ss.ffff";



        public void StartTimer()
        {
            stopWatch = new Stopwatch();

            timer = new DispatcherTimer();
            timer.Tick += new EventHandler(timeDispatcher);
            timer.Interval = new TimeSpan(0, 0, 1);
            stopWatch.Start();
            timer.Start();

        }



        private void timeDispatcher(object sender, EventArgs e)
        {
            TimeElapsed = stopWatch.Elapsed.ToString(); // Format as you wish

            notifyPropertyChanged("TimeElapsed");
        }


        private void notifyPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
